local qide = fk.CreateSkill{
  name = "wk_heg__qide",
}

Fk:loadTranslationTable{
  ["wk_heg__qide"] = "齐德",
  [":wk_heg__qide"] = "当你受到伤害后，你可以令一名体力值等于你的其他角色摸一张牌，然后其可以弃置一张手牌，令你摸一张牌。",
  ["#wk_heg__qide_prompt"] = "齐德：你可以选择一名体力值等于你的其他角色，令其摸一张牌",
  ["#wk_heg__qide_discardPrompt"] = "齐德：你可以弃置一张牌，令 %dest 摸一张牌",

}

qide:addEffect(fk.Damaged, {
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill(self) and player == target and table.find(player.room:getOtherPlayers(player, false), function (p)
      return player.hp == p.hp
    end)
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local to = room:askToChoosePlayers(player, {
      targets = table.filter(player.room:getOtherPlayers(player, false), function (p)
        return player.hp == p.hp
      end),
      min_num = 1,
      max_num = 1,
      skill_name = qide.name,
      prompt = "#wk_heg__qide_prompt"
    })
    if #to > 0 then
      event:setCostData(self, {to = to[1]})
      return true
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local to = event:getCostData(self).to
    to:drawCards(1, qide.name)
    if to.dead or to:isNude() then return end
    if #room:askToDiscard(to, {
      min_num = 1,
      max_num = 1,
      include_equip = false,
      skill_name = qide.name, true, 
      prompt = "#wk_heg__qide_discardPrompt::"..player.id}) > 0 then
      player:drawCards(1, qide.name)
    end
  end
})

return qide